﻿@model PlmTurnoverViewModel
@{
    Layout = null;
    ViewBag.Title = "人员变动申报添加";
}
<script src="/Scripts/jQuery/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jQuery/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script type="text/javascript">
    function dialogRefresh(json) {
        DWZ.ajaxDone(json);
        if (json.statusCode == DWZ.statusCode.ok) {
            $("#pagerForm", navTab.getCurrentPanel()).submit();
            $.pdialog.closeCurrent();
        }
    }
</script>
<script type="text/javascript">
    $(function () {
        getSection();
        $("#section").change(function () {
            var unitCode = $("#section").find("option:selected").text();
            getSectionName(unitCode);
            getPersonnel(unitCode);
            getPosition(unitCode);
        });
        $("#position").change(function () {
            var unitCode = $("#section").find("option:selected").text();
            var positId = $("#position").find("option:selected").text();
            getPersonnelByPosition(unitCode, positId);
        });
        $("#nowname").change(function () {
            nowchange();
        });
        $("#changename").change(function () {
            changedchange();
        });
    }
        );
    /*打开添加页时，获取所属标段*/
    function getSection() {
        $.getJSON(
            "/PersonnelLog/PlmTurnover/GetSection",
            function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["UNIT_CODE"]).text(item["UNIT_CODE"]).appendTo($("#section"));
                }

                );
            }
            );
    }
    /*根据所选标段ID，获取所属标段*/
    function getSectionName(unitCode) {
        $("#reportunit").empty();
        $.getJSON(
            "/PersonnelLog/PlmTurnover/getSectionName?code=" + unitCode + "",
            function (data) {
                $("#reportunit").val(data["UNIT_NAME"]);
            });
    }
    /*根据所选标段ID，获取该标段下人员名称*/
    function getPersonnel(unitCode) {

        $("#nowname").empty();
        $("#changename").empty();
        $.getJSON(
            "/PersonnelLog/PlmTurnover/GetNameBySection?code=" + unitCode + "",
            function(data) {
                $.each(data,
                    function(i, item) {
                        $("<option></option>").val(item["Pi_ID"]).text(item["Pi_Name"]).appendTo($("#changename"));
                    }
                );
            });
        $("#nowname").prepend("<option value='0'>=请选择=</option>");
        $("#changename").prepend("<option value='0'>=请选择=</option>");
    }
    /*根据所选标段ID，获取对应职位（检测职位或监理职位）*/
    function getPosition(unitCode) {
        $("#position").empty();
        $.getJSON(
            "/PersonnelLog/PlmTurnover/GetPositionBySectionID?code=" + unitCode + "",
            function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["Scd_ID"]).text(item["Scd_Name"]).appendTo($("#position"));
                    $("#changetype").val(item["Scd_ParentID"]);
                });
            }
            );
        $("#position").prepend("<option value='0'>=请选择=</option>");
    }
    /*根据所选标段ID、职位信息 获取该标段下该职位人员名称*/
    function getPersonnelByPosition(unitCode, positId) {
        debugger;
        $("#nowname").empty();
        $.getJSON(
            "/PersonnelLog/PlmTurnover/GetNameByPositionID?section=" + unitCode + "&positionid=" + escape(positId) + "",
            function(data) {
                $.each(data,
                    function(i, item) {
                        debugger;
                        $("<option></option>").val(item["Pi_ID"]).text(item["Pi_Name"]).appendTo($("#nowname"));

                    });
            }
        );
        $("#nowname").prepend("<option value='0'>=请选择=</option>");
    }
    /*根据人员名称加载人员职称和证书编号*/
    function nowchange() {
        var Id = $("#nowname").find("option:selected").val();

        $("#nowProfessional").empty();
        $("#nowLicenseNum").empty();
        $.getJSON(
            "/PersonnelLog/PlmTurnover/GetPersonnelByID?id=" + Id + "",
            function(data) {
                $.each(data,
                    function(i, item) {
                        $("#nowProfessional").val(item["Pi_Professional"]);
                        $("#nowLicenseNum").val(item["Pi_LicenseNum"]);
                    });
            }
        );
    }
    function changedchange() {
        $("#changeProfessional").empty();
        $("#changeLicenseNum").empty();
        $.getJSON(
            "/PersonnelLog/PlmTurnover/GetPersonnelByID?id=" + $("#changename").find("option:selected").val() + "",
            function(data) {
                $.each(data,
                    function(i, item) {
                        $("#changeProfessional").val(item["Pi_Professional"]);
                        $("#changeLicenseNum").val(item["Pi_LicenseNum"]);
                    });
            }
        );
    }
</script>
@{Html.EnableClientValidation();}
@using (Html.BeginForm("TurnooverAddData", "PlmTurnover", null, FormMethod.Post, new { onsubmit = "return validateCallback(this,dialogRefresh);", @class = "pagerForm required-validate" }))
{
@*<form method="post" action="@Url.Action("TurnooverAddData", "PlmTurnover")" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone)">*@
<div class="pageFormContent sortDrag" layouth="58">
    <table class="tab01 tabNo" width="100%">
        <tr>
            <td class="td1" style="width:35%;">
                申报人：
            </td>
            <td>
                <input type="hidden" id="changetype" name="changetype" />
                <input id="AssistID" name="AssistID" value="@ViewBag.AssisId" type="hidden"/>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_Applicant, new { @class = "input02" })
            </td>
        </tr>
        <tr>
            <td class="td1">
                申报日期：
            </td>
            <td>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_DeclarationDate, new { @class = "date input02", Value = DateTime.Now.ToString("yyyy-MM-dd") })
            </td>
        </tr>
        <tr>
            <td class="td1">
                所属标段：
            </td>
            <td>
                <select id="section" name="section">
                    <option>请选择</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="td1">
                变动职位：
            </td>
            <td>
                <select id="position" name="position">
                    <option>请选择</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="td1">
                申报单位：
            </td>
            <td>
                <input id="reportunit" class="input02" readonly="readonly" />
            </td>
        </tr>
        <tr>
            <td class="td1">
                现职人员姓名：
            </td>
            <td>
                <select id="nowname" name="nowname" onchange="nowchange()">
                    <option>请选择</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="td1">
                变更人员姓名：
            </td>
            <td>
                <select id="changename" name="changename" onchange="changedchange()">
                    <option>请选择</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="td1">
                现职人员职称：
            </td>
            <td>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_NowProfessional, new { id = "nowProfessional", @readonly = "true", @class = "input02" })
            </td>
        </tr>
        <tr>
            <td class="td1">
                变更人员职称：
            </td>
            <td>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_ChangeProfessional, new { id = "changeProfessional", @readonly = "true", @class = "input02" })
            </td>
        </tr>
        <tr>
            <td class="td1">
                现职人员证书编号：
            </td>
            <td>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_NowLicenseNum, new { id = "nowLicenseNum", @readonly = "true", @class = "input02" })
            </td>
        </tr>
        <tr>
            <td class="td1">
                变更人员证书编号：
            </td>
            <td>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_ChangeLicenseNum, new { id = "changeLicenseNum", @readonly = "true", @class = "input02" })
            </td>
        </tr>
        <tr>
            <td class="td1">
                变更原因：
            </td>
            <td>
                @Html.TextBoxFor(model => model.ThePlmTurnoverInfoInfo.T_Reason, new Dictionary<string, object> { { "class", "data-val-required input05" }})
                @Html.ValidationMessageFor(model => model.ThePlmTurnoverInfoInfo.T_Reason)
               @* @Html.TextAreaFor(model => model.ThePlmTurnoverInfoInfo.T_Reason, new { @class = "required input05", cols = "100", rows = "6" })*@
            </td>
        </tr>
        <tr>
            <td class="td1">
                变更人电子签名：
            </td>
            <td>
                <a href='/Common/UploaderFile/Uploader/?id=ZDFileID' width="710" height="460" rel="rel_WorkFlow_WorksMeasure_Attach"
                    mask="true" target="dialog" title="附件管理">
                    <img src="/Content/themes/default/images/fj.gif" alt="查看附件" id='ZDFileID' 
                       uploaderoption="{MoudleID:@ViewBag.MoudleID,'ToSelectIDs':[@ViewBag.FileIds],'ToDeleteIDs':[@ViewBag.DeleteIds],BizDeleteURL:'/PersonnelLog/Base/Delete/',BizSaveUrl:'/PersonnelLog/Base/BatchAdd/',BizType:'TurnOver_Rules',BizID:'@ViewBag.AssisId','dirWhere':'@ViewBag.DirWhere'}" />
                </a>
            </td>
        </tr>
        @*            <dl class="nowrap">
                <td>预览：</td>
                <td>
                    <img src="../../Content/uploadify/img/moren.png" height="70" />
                </td>
            </tr>*@
    </table>
</div>
<div class="formBar">
    <ul>
        <li>
            <button type="submit" class="btn btn-sm">
                保存</button>
        </li>
        <li>
            <button type="button" class="close btn btn-default btn-sm">
                取消</button>
        </li>
    </ul>
</div>
@*</form>*@
}
